<script setup>
  const props = defineProps(['todoList'])
  // console.log(props.todoList[0]);

  const emits = defineEmits()

  const destroy = (index) => {
    emits('del-todo', index)
  }
</script>
<template>
  <section class="main">
    <input
      id="toggle-all"
      class="toggle-all"
      type="checkbox"
    />
    <label for="toggle-all">Mark all as complete</label>
    <ul class="todo-list">
      <li
        v-for="item, index in todoList"
        :key="item.id"
        :class="{completed : item.finished}"
      >
        <div class="view">
          <input
            class="toggle"
            type="checkbox"
            v-model="item.finished"
          />
          <label>{{ item.name }}</label>
          <button
            class="destroy"
            @click="destroy(index)"
          ></button>
        </div>
      </li>
    </ul>
  </section>
</template>